package com.njlime.sys.repository;

import com.njlime.core.base.repository.impl.BaseDaoImpl;
import com.njlime.sys.entities.RegularTask;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Dean on 2017-7-27.
 */
@Repository
public class RegularTaskDaoImpl extends BaseDaoImpl<RegularTask> {

    /**
     * 根据名称获取定时任务
     * @param jobName
     */
    public RegularTask getByJobName(String jobName){
        StringBuilder sb = new StringBuilder();
        List<Object> arrList = new ArrayList<Object>();
        sb.append("select * from t_regular_task where name = ? ");
        arrList.add(jobName);
        return findOne(sb.toString(),arrList);
    }

    /**
     * 获取未执行的任务列表
     * @return
     */
    public List<RegularTask> getJobList(){
        StringBuilder sb = new StringBuilder();
        sb.append("select * from t_regular_task where status = 0 or status = 2 ");
        return findList(sb.toString(),null);
    }
}
